package com.si.util;

import java.util.List;

import javax.servlet.ServletContext;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.ServletContextAware;

import com.si.entity.Blogroll;
import com.si.entity.Bottom;
import com.si.entity.InfoTypeClassA;
import com.si.service.BlogrollService;
import com.si.service.BottomService;
import com.si.service.InfoTypeClassAService;

public class InitDataListener implements InitializingBean, ServletContextAware {

	@Autowired
	private InfoTypeClassAService infoTypeService;
	@Autowired
	private BlogrollService blogrollService;
	@Autowired
	private BottomService bottomService;
	
	public void setServletContext(ServletContext arg0) {
		//加载菜单数据
		List<InfoTypeClassA> infoTypeClassAList=infoTypeService.getAll();
		arg0.setAttribute("infoTypeClassAList", infoTypeClassAList);
		//加载友情链接
		List<Blogroll> blogrollList=blogrollService.getAll();
		arg0.setAttribute("blogrollList", blogrollList);
		//网站底部信息
		List<Bottom> bottomList=bottomService.getAll();
		arg0.setAttribute("bottomList", bottomList);
	}
	
	public void afterPropertiesSet() throws Exception {
	
	}
}
